package book.ch9;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

class ReaderListener implements ActionListener{
    public void actionPerformed(ActionEvent e){
        String str=e.getActionCommand();
        System.out.println(str+":"+str.length());
    }
}

class WindowActionEvent extends JFrame{
    public WindowActionEvent(){
        setLayout(new FlowLayout());
        setBounds(100,100,310,260);
        JTextField text=new JTextField(10);
        add(text);

        ReaderListener listener=new ReaderListener();
        text.addActionListener(listener);

        setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}

public class E9_6 {
    public static void main(String[] args) {
        WindowActionEvent win=new WindowActionEvent();
    }
}
